#include "algebra3.h"
#include "ball.h"
#include "global.h"
#include "physics.h"

#include <vector>

class Table {

public:
	Table();
	Table(vec2 lowerLeft, vec2 upperRight);
	void drawTable();
	void addBall(Ball b);
	bool legalBall(Ball b);
	void simulate(double time);
	double dist(vec2 loc1, vec2 loc2);

private:

	double findMaxVelocity();
	double findCollidingBallsInterval();
	double findCollidingWallInterval();
	void moveBalls(double time);
	void fixBallCollisions();
	void fixWallCollisions();
	double tInterval();

	vec2 ll;
	vec2 ur;
	vector<Ball> balls;
	double BALL_RADIUS;
	Physics p;
};